home *** CD-ROM | disk | FTP | other *** search
/ Light ROM 1 / LIGHT-ROM 1 (Amiga Library Services)(1994).iso / ffdisks / d909.lha / GoldED2 / Tools / HiSpeed / arexx / Zweckform.rexx < prev    next >
OS/2 REXX Batch file  |  1993-08-28  |  7KB  |  254 lines

  1. /* Prints (disk-)labels; done on suggestion of Olivier Toebosch    */
  2. /* The label carrier (one sold by 'Zweckform') is supposed to      */
  3. /* look like this:                                                 */
  4. /*                                                                 */
  5. /*     ----------------------------------------------              */
  6. /*     |                                             | top offfset */
  7. /*     |---------------------------------------------|             */
  8. /*     |              |              |               |             */
  9. /*     |              |              |               | 3 columns  */
  10. /*     |              |              |               | 5 rows      */
  11. /*     |---------------------------------------------|             */
  12. /*     |              |              |               |             */
  13. /*     |              |              |               |             */
  14. /*     |              |              |               |             */
  15. /*     |---------------------------------------------|             */
  16. /*     |              |              |               |             */
  17. /*     |              |              |               |             */
  18. /*     |              |              |               |             */
  19. /*     |---------------------------------------------|             */
  20. /*     |              |              |               |             */
  21. /*     |              |              |               |             */
  22. /*     |              |              |               |             */
  23. /*     |---------------------------------------------|             */
  24. /*     |              |              |               |             */
  25. /*     |              |              |               |             */
  26. /*     |              |              |               |             */
  27. /*     |---------------------------------------------|             */
  28. /*     |                                             | bottom      */
  29. /*     ----------------------------------------------  margin      */
  30.  
  31. columns = 3     /* number of labels/line                           */
  32. rows    = 5     /* number of lines                                 */
  33. toffset = 22    /* top border    (must be at least 5 mm)           */
  34. boffset = 22    /* bottom margin (must be at least 5-7 mm)         */
  35. paperx  = 210   /* paper width  [mm]                               */
  36. papery  = 298   /* paper height [mm]                               */
  37.  
  38. /* ----------------------------------------------------------------*/
  39.  
  40. options results
  41. shell
  42.  
  43. address HISPEED.1
  44.  
  45. SET BOOK     OFF
  46. SET HEADER   OFF          /* 5 mm still remain unusable :-(       */
  47. SET DX 7                  /* i.e. left/right border = 3.5 mm      */
  48. SET DY 10
  49.  
  50. 'SET PAPERX' 210 + 7      /* add 7 mm for right border            */
  51. 'SET PAPERY' papery
  52.  
  53. SET SEPARATE OFF
  54.  
  55. SET LAYOUTX columns * 2   /* two columns/label                    */
  56. SET LAYOUTY rows
  57.  
  58. SET QUALITY BOLD
  59.  
  60. SET TOP    toffset + 5
  61. SET BOTTOM boffset
  62. SET LEFT   7
  63. SET RIGHT  7
  64.  
  65. /* consider position of DeskJet's middle platen (used as guide): */
  66.  
  67. QUERY BLOCKX  /* maximum entry length [characters] incl. CR */
  68.  
  69. blockx  = trunc(RESULT) - 1
  70. labels  = columns * rows
  71.  
  72. if (blockx < 25) then do
  73.  
  74.   SET WARN " You should select a smaller font ;-)"
  75.  
  76. end
  77.  
  78. say ""
  79. say " This script does support printing on labels by Zweckform "
  80. say " (70 * 50.8 mm, on a 3 x 5 carrier), 2 columns per label. "
  81. say ""
  82. say " Tell me the number of the 1st label you want to print or "
  83. say " 0 to exit. The sheet's top left label is considered to be"
  84. say " 1, its right neighbour 2, the last label is " || labels
  85.  
  86. pull first
  87.  
  88. if (first < 1) | (first > labels) then do
  89.  
  90.   say " Done (please close window)."
  91.   exit
  92.  
  93. end
  94.  
  95. say ""
  96. say " I'm going to ask you for directories to scan. File- and  "
  97. say " directory names will be used as label text (except system"
  98. say " directories as 'FONTS' or icon files) ..."
  99.  
  100. QUERY BLOCKY           /* how many lines can be printed on a label ? */
  101. lines = RESULT
  102.  
  103. maxEntries = lines * 2 /* max. number of entries/label (two columns) */
  104.  
  105. /* remove 'waste' of last run (if any) */
  106.  
  107. shell
  108. DELETE ">NIL:" "T:LABELTEXT"
  109. address HISPEED.1
  110.  
  111. /* open 'label' file (will become output file) */
  112.  
  113. R = open('txt', "T:LABELTEXT", 'WRITE')
  114.  
  115. if (R = 0) then do
  116.   SET WARN "Error - couldn't create temporary file"
  117.   exit
  118. end
  119.  
  120. /* 'jump' to first label */
  121.  
  122. if (first > 1) then do
  123.   do piece = 0 to (first - 2)
  124.     do n = 1 to maxEntries
  125.         R = writeln('txt', "")
  126.     end
  127.   end
  128. end
  129.  
  130. /* Read directory. The original OS2.04 'list' command _must_ be  */
  131. /* available since we depend on the layout !                     */
  132.  
  133. piece     = first - 1  /* count used labels   */
  134. terminate = 0          /* user-interrupt flag */
  135.  
  136. do while (terminate = 0) & (piece < labels)
  137.  
  138.   say ""
  139.   say " PREPARE LABEL Nº" (piece + 1) ":"
  140.   say " Enter path to scan (e.g. DF0:) or <CR> to terminate."
  141.  
  142.   pull path
  143.  
  144.   if path = "" then
  145.  
  146.     terminate = 1
  147.  
  148.   else do
  149.  
  150.     /* Create directory list (last line/first line have to be ignored */
  151.  
  152.     say " scanning " path "..."
  153.  
  154.     shell
  155.     LIST path " TO T:TEMP"
  156.  
  157.     /* Read list & count lines */
  158.  
  159.     address HISPEED.1
  160.  
  161.     R = open('ls', "T:TEMP", 'READ')
  162.  
  163.     entries = 0
  164.  
  165.     void = readln('ls')    /* ignore header line */
  166.  
  167.     do until EOF('ls') | (entries > maxEntries)
  168.  
  169.       iodata = readln('ls')
  170.       iodata = upper(iodata)
  171.  
  172.       parse var iodata name type rest
  173.  
  174.       if ~EOF('ls') then
  175.         if right(name, 5) ~= ".INFO" then
  176.           if name ~= "S" then
  177.             if name ~= "DEVS" then
  178.               if name ~= "L" then
  179.                 if name ~= "LIBS" then
  180.                   if name ~= "FONTS" then
  181.                      if name ~= "T" then
  182.                       if name ~= "ENV" then
  183.                         if name ~= "C" then do
  184.                           if type = "DIR" then
  185.                             entry.entries = left(name, blockx - 3) || " []"
  186.                           else
  187.                             entry.entries = left(name, blockx)
  188.                           entries = entries + 1
  189.                         end
  190.     end
  191.  
  192.     R = close('ls')
  193.  
  194.     /* create the next label (i.e. write detected file names to output file) */
  195.  
  196.     if (entries > maxEntries) then
  197.       do
  198.         say ""
  199.         say " Sorry, too many files/directories. Some of them won't"
  200.         say " get printed (maximum is " maxEntries ")."
  201.       end
  202.     else
  203.       say " "entries " entries detected (maximum is " maxEntries ")"
  204.  
  205.     do n = 1 to maxEntries
  206.  
  207.       if n < entries then
  208.         do
  209.           index = n - 1
  210.           R = writeln('txt', entry.index)
  211.         end
  212.       else
  213.           R = writeln('txt', "")
  214.     end
  215.  
  216.     if (entries = 0) then
  217.       do
  218.         say ""
  219.         say " No files found. Please have another try ..."
  220.       end
  221.     else
  222.       piece = piece + 1
  223.  
  224.   end
  225.  
  226. end
  227.  
  228. R = close('txt')
  229.  
  230. CLR
  231. SET FILE "T:LABELTEXT"
  232.  
  233. /* anything to print ? */
  234.  
  235. QUERY JOBS
  236.  
  237. if RESULT = 0 then
  238.  
  239.   SET WARN " Couldn't set files. Maybe empty ?!"
  240.  
  241. else do
  242.  
  243.   SET ASK " Proceed with printing (Y/N) ?"
  244.   if RESULT = 1 then
  245.       PRINT
  246. end
  247.  
  248. /* clean up ...  */
  249.  
  250. shell
  251. DELETE ">NIL:" "T:TEMP"
  252.  
  253. say " Ready (please close window)."
  254.